package com.wanbangee.marksystem.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.wanbangee.marksystem.entities.StatisticsAverageRanking;
import com.wanbangee.marksystem.entities.StatisticsSubReport;
import com.wanbangee.marksystem.service.MExamServiecApi;
import com.wanbangee.marksystem.service.SelectStatistisGradeReportServiceApi;
import com.wanbangee.marksystem.service.StatisticsScoreReportService;
import com.wanbangee.marksystem.service.StatistisGradeReportService;

@RestController
@RequestMapping("/gradeScoreAnalyze")
public class SelectGradeReportController {
	@Autowired
	public MExamServiecApi mExamServiecApi;

	@Autowired
	public SelectStatistisGradeReportServiceApi selectStatistisGradeReportServiceApi;

	@Autowired
	public StatistisGradeReportService statistisGradeReportService;
	
	@Autowired
	public StatisticsScoreReportService statisticsScoreReportService;
	

	// 查询当所选年级的所有考试
	@RequestMapping(value = "selectGradeBySchId", method = RequestMethod.GET)
	public Map<String, Object> selectExamByGraId(@RequestParam("schId") Integer schId) {

		return this.selectStatistisGradeReportServiceApi.selectGradeByschId(schId);
	}

	// 查询当所选年级的所有考试
	@RequestMapping(value = "selectGradeBySchId ", method = RequestMethod.GET)
	public Map<String, Object> selectGradeBySchId(@RequestParam("graId") Integer graId) {

		return this.mExamServiecApi.selectExamBygraId(graId);
	}

	// 查询各科平均分/总分
	@RequestMapping(value = "selectSubAvgSum", method = RequestMethod.GET)
	public Map<String, Object> selectSubAvgSum(@RequestParam("examId") Integer examId) {
		Map<String, Object> responseMap = new HashMap<>();
		List<StatisticsSubReport> statisticsSubReport = this.statistisGradeReportService.selectAvgAndTotal(examId);
		responseMap.put("message", "接口成功");
		responseMap.put("code", 1001);
		responseMap.put("StatisticsSubReport", statisticsSubReport);
		return responseMap;
	}
	
	//查询各班级名称/人数/评分均/班主任/最高分/最低分
	@RequestMapping(value = "selectClassAnalyzeInfo", method = RequestMethod.GET)
	public Map<String, Object> selectClassAnalyzeInfo(@RequestParam("examId") Integer examId,@RequestParam("subId") Integer subId) {
		//Map<String, Object> responseMap = (Map<String, Object>) this.statistisGradeReportService.selectStatisticsAverageRankingByExamIdAndSubId(examId, subId);
		Map<String, Object> responseMap = new HashMap<>();
		List<StatisticsAverageRanking> statisticsAverageRanking = this.statistisGradeReportService.selectStatisticsAverageRankingByExamIdAndSubId(examId, subId);
		responseMap.put("message", "接口成功");
		responseMap.put("code", 1001);
		responseMap.put("statisticsAverageRanking", statisticsAverageRanking);
		return responseMap;
	}
	
	//查询总平均分/满分/年级/班级数/人数
		@RequestMapping(value = "selectTotalAvgFullScoreGradeNmClassNumStuNum", method = RequestMethod.GET)
		public Map<String, Object> selectTotalAvgFullScoreGradeNmClassNumStuNum(@RequestParam("examId")Integer examId) {
			//Map<String, Object> responseMap = (Map<String, Object>) this.statistisGradeReportService.selectStatisticsAverageRankingByExamIdAndSubId(examId, subId);
			Map<String, Object> responseMap = (Map<String, Object>) this.statistisGradeReportService.selectAvgAndTotalScoreByexamId(examId);
			responseMap.put("message", "接口成功");
			responseMap.put("code", 1001);
			return responseMap;
		}
	
	
	
}
